import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters(['userInfo'])
  },
  data() {
    return {

    }
  },
  methods: {
    // 根据当前身份获取对应类型的机构列表
    getUserOrgTypeOrganizationList(type, query) {
      return new Promise((resolve, reject) => {
        // 连锁身份
        if (type === 5) {
          this.$api.getStoreOrganizationList({
            returnCount: true,
            page: 1,
            pageSize: 10,
            organizationType: type,
            organizationName: query.trim()
          }).then(res => {
            const list = res?.list || []
            resolve(list)
          }).catch(err => {
            reject(err)
          })
        } else if (type === 6) {
          this.$api.getSupplierList({
            returnCount: true,
            page: 1,
            pageSize: 10,
            supplierOrganizationName: query.trim()
          }).then(res => {
            const list = res?.list || []
            if (list.length > 0) {
              list.forEach(item => {
                item.organizationId = item.supplierOrganizationId
              })
            }
            resolve(list)
          }).catch(err => {
            reject(err)
          })
        } else if (type === 4) {
          this.$api.getSupportSupplyOrganizationByMe({
            returnCount: true,
            page: 1,
            pageSize: 10
          }).then(res => {
            const list = res?.list || []

            resolve(list)
          })
        }
      })
    }
  }
}
